#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/wait.h>

int main()
{
  pid_t id = fork();
  if(id == 0)
  {
    execl("/home/xsc/gitee/linux-learning/12.06/a.out","./a.out",NULL);
    exit(1);
  }
  sleep(1);
  printf("father wait begin!\n");
  int status;
  int ret;
    ret = waitpid(-1,&status,0);//阻塞式等待
    if(ret == 0)
    {
      printf("child is running!\n");
      sleep(1);
    } 
  if(WIFEXITED(status))
    printf("father wait success!,status_exit_code : %d status_exit_signal:%d\n",WEXITSTATUS(status),(status)&0x7F);
  else{
    printf("father wait falure,status:%d\n",status);
  }
  return 0;
}
